<template>
  <div class="box">
    <div v-if="loginState===0" class="icon_box">
      <img src="@/assets/img/computer.png">
      <span class="txt">登录在线微信</span>
    </div>
    <div v-if="loginState===1" class="icon_box">
      <img src="@/assets/img/computer.png">
      <span class="txt">登录在线微信成功</span>
    </div>
    <div v-if="loginState===2" class="icon_box">
      <img src="@/assets/img/computer.png">
      <span class="txt">取消登录成功</span>
    </div>
    <div class="login">
      <button v-if="loginState===0" class="btn" @click="login(1)">登录微信</button>
      <span v-if="loginState===0" class="cancel" @click="login(2)">取消登录</span>
    </div>
  </div>
</template>

<script setup>

import {onMounted, ref} from "vue";
import {useRoute} from "vue-router";
import {conformLogin, scanCode} from "@/api/login/index.js";

  const route = useRoute();

  const uuid = ref("");

  let loginState = ref(0)

  function login(loginType){
    loginState.value = loginType
    conformLogin({'uuid':uuid.value,"loginType":loginType})
  }

  onMounted(()=>{
    if (route.query.uuid){
      uuid.value = route.query.uuid
      // 扫码标识提醒
      scanCode({'uuid':uuid.value});
    }
  })
</script>

<style scoped lang="less">
.box{
  height: 100vh;
  display: flex;
  flex-direction:column;
  justify-content: space-around;
  .icon_box{
    display: flex;
    align-items: center;
    flex-direction:column;
  }
  img{
    display: block;
    width: 88px;
  }
  .txt{
    margin-top: 10px;
    color: #000;
    letter-spacing:1px;
    font-size: 25px;
  }

}
.btn{
  color: #fff;
  letter-spacing:2px;
  font-weight: 700;
  background-color: #07c160;
  border: none;
  padding: 6px 0;
  border-radius: 5px;
  cursor: pointer;
}
.login{
  display: flex;
  flex-direction:column;
}
.cancel{
  margin-top: 20px;
  color: #435eb0;
  letter-spacing:2px;
}
</style>